namespace Test
import Grawlix

struct A:
	
	public val as double
	
	[Comparison]
	private def Comparison(rhs as A):
		return val - rhs.val


a = A()
a.val = 0.0
b as System.IComparable = a
c as System.IComparable[of A] = a
d as object = a
#w as A = null # A is a value type
x as System.IComparable = null
y as System.IComparable[of A] = null
z as object = null

assert 0== a.CompareTo(a)
assert 0== a.CompareTo(b)
assert 0== a.CompareTo(c)
assert 0== a.CompareTo(d)
#assert 0!= a.CompareTo(w) # no w
assert 0!= a.CompareTo(x)
#assert 0!= a.CompareTo(y) # See BOO-1061
assert 0!= a.CompareTo(z)
assert 0!= a.CompareTo(null)

assert 0== b.CompareTo(a)
assert 0== b.CompareTo(b)
assert 0== b.CompareTo(c)
assert 0== b.CompareTo(d)
#assert 0!= b.CompareTo(w) # no w
assert 0!= b.CompareTo(x)
assert 0!= b.CompareTo(y)
assert 0!= b.CompareTo(z)
assert 0!= b.CompareTo(null)

assert 0== c.CompareTo(a)
assert 0== c.CompareTo(b)
assert 0== c.CompareTo(c)
assert 0== c.CompareTo(d)
#assert 0!= c.CompareTo(w) # no w
#assert 0!= c.CompareTo(x) # See BOO-1061
#assert 0!= c.CompareTo(y) # See BOO-1061
#assert 0!= c.CompareTo(z) # See BOO-1061
#assert 0!= c.CompareTo(null) # Cannot convert null to A

assert not a < a
#assert not a < w # no w
#assert not a < null # Cannot convert null to A
assert     a <= a
#assert not a <= w # no w
#assert not a <= null # Cannot convert null to A
assert not a > a
#assert     a > w # no w
#assert     a > null # Cannot convert null to A
assert     a >= a
#assert     a >= w # no w
#assert     a >= null # Cannot convert null to A

# no w
#assert     w < a
#assert not w < w
#assert not w < null
#assert     w <= a
#assert     w <= w
#assert     w <= null
#assert not w > a
#assert not w > w
#assert not w > null
#assert not w >= a
#assert     w >= w
#assert     w >= null

 # Cannot convert null to A
#assert     null < a
#assert not null < w
#assert     null <= a
#assert     null <= w
#assert not null > a
#assert not null > w
#assert not null >= a
#assert     null >= w
